// import stateCode from '@/js/stateCode'

export default {
    // (数据库)向列表中添加
    ADD(state, payload) {
        if (payload.list) {
            // 数据预处理
            let list = payload.list;
            for (let i = 0; i < list.length; i++) {
                if (list[i].PMCID) {
                    state.dataList.push(list[i]);
                }
            }
        }
    },

    // (数据库)覆盖列表
    COVER(state, payload) {
        if (payload.list) {
            // 数据预处理
            let list = payload.list;
            let dataList = [];
            for (let i = 0; i < list.length; i++) {
                if (list[i].PMCID) {
                    dataList.push(list[i]);
                }
            }
            state.dataList = dataList;
        }
    },

    // 改变某一行数据的状态
    UPDATESTATE(state, payload) {
        let id = payload.PMCID;
        let statecode = payload.state;
        let list = payload.list;

        // 传入id 或 list
        if (id) {
            state.dataList.find(i => i.PMCID == id).state = statecode;
        }
        else if (list) {
            list.forEach(id => {
                state.dataList.find(i => i.PMCID == id).state = statecode;
            });
        }
    }
};